package com.ruoyi.web.controller.comlbs;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.PlatformManagement;
import com.ruoyi.system.service.IPlatformManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 运管平台管理Controller
 * 
 * @author wp
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/comlbs/platformManagement")
public class PlatformManagementController extends BaseController
{
    @Autowired
    private IPlatformManagementService platformManagementService;

    /**
     * 查询运管平台管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlatformManagement platformManagement)
    {
        startPage();
        List<PlatformManagement> list = platformManagementService.list();
        return getDataTable(list);
    }

    /**
     * 导出运管平台管理列表
     */
    @Log(title = "运管平台管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlatformManagement platformManagement)
    {
        List<PlatformManagement> list = platformManagementService.list();
        ExcelUtil<PlatformManagement> util = new ExcelUtil<PlatformManagement>(PlatformManagement.class);
        util.exportExcel(response, list, "运管平台管理数据");
    }

    /**
     * 获取运管平台管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(platformManagementService.getById(id));
    }

    /**
     * 新增运管平台管理
     */
    @Log(title = "运管平台管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformManagement platformManagement)
    {
        return toAjax(platformManagementService.save(platformManagement));
    }

    /**
     * 修改运管平台管理
     */
    @Log(title = "运管平台管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformManagement platformManagement)
    {
        return toAjax(platformManagementService.saveOrUpdate(platformManagement));
    }

    /**
     * 删除运管平台管理
     */
    @Log(title = "运管平台管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(platformManagementService.removeByIds(Arrays.asList(ids)));
    }
}
